package org.jeecg.modules.tt_question_collect.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.api.client.json.Json;
import com.xkcoding.justauth.AuthRequestFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import me.zhyd.oauth.request.AuthRequest;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.formula.functions.T;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.test.entity.JeecgDemo;
import org.jeecg.modules.demo.test.service.IJeecgDemoService;
import org.jeecg.modules.demo.test.service.impl.JeecgDemoServiceImpl;
import org.jeecg.modules.system.controller.SysPermissionController;
import org.jeecg.modules.tt_question_collect.entity.TtQuestionCollect;
import org.jeecg.modules.tt_question_collect.entity.wtexport;
import org.jeecg.modules.tt_question_collect.service.ITtQuestionCollectService;
import org.jeecg.modules.tt_question_collect.service.IWtexportService;
import org.jeecg.modules.tt_question_collect.util.TransUntil;
import org.jeecgframework.poi.excel.ExcelExportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
* @Description: 出具方案表
* @Author: jeecg-boot
* @Date:   2021-03-09
* @Version: V1.0
*/
@Api(tags="test")
@Slf4j

@RestController
public class TestController extends JeecgController<wtexport, IWtexportService> {


    @Value("${justauth.type.WECHAT_ENTERPRISE_WEB.client-id}")
    private String clientid;
    @Value("${justauth.type.WECHAT_ENTERPRISE_WEB.client-secret}")
    private String clientsecret;
    @Autowired
    private AuthRequestFactory factory;

    @Autowired
   private IWtexportService IWtexportService;

   @Autowired
   private IJeecgDemoService jeecgDemoService;

    @Autowired
    private ITtQuestionCollectService ttquestioncollectService;





    @AutoLog(value = "查看文件列表")
    @ApiOperation(value = "查看文件列表", notes = "查看文件列表")
    @GetMapping(value = "/seefilelist/{id}")
    public Result<?> seeFileList(@PathVariable String id) {
        //查询
        List<Map<String, Object>> list = IWtexportService.getfilelist(id);
        list = TransUntil.transformLowerCase(list);
        System.out.println(list);
        return Result.OK(list) ;
    }



    @AutoLog(value = "同步更新企业微信组织架构")
    @ApiOperation(value = "同步更新企业微信组织架构", notes = "同步更新企业微信组织架构")
    @GetMapping(value = "/tbupdatewechat")
    public Result<?> Wechat_Tb_ud() {
        String source ="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid="+clientid+"&corpsecret="+clientsecret;

        AuthRequest authRequest = factory.get(source);

        System.out.println(authRequest);
        return Result.OK();
    }





}
